package com.luoxiang.socialandroid.activity;

import static com.luoxiang.lib_common.common.Constants.MmkvConst.EXTRA;
import static com.luoxiang.lib_common.common.Constants.MmkvConst.HOSTAUDIT;
import static com.luoxiang.lib_common.common.Constants.MmkvConst.KEY;
import static com.luoxiang.lib_common.common.Constants.MmkvConst.TOKEN;
import static com.luoxiang.socialandroid.face.utils.ZipUtils.TAG;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.sdk.android.oss.ClientConfiguration;
import com.alibaba.sdk.android.oss.ClientException;
import com.alibaba.sdk.android.oss.OSS;
import com.alibaba.sdk.android.oss.OSSClient;
import com.alibaba.sdk.android.oss.ServiceException;
import com.alibaba.sdk.android.oss.callback.OSSCompletedCallback;
import com.alibaba.sdk.android.oss.callback.OSSProgressCallback;
import com.alibaba.sdk.android.oss.common.auth.OSSCredentialProvider;
import com.alibaba.sdk.android.oss.common.auth.OSSStsTokenCredentialProvider;
import com.alibaba.sdk.android.oss.internal.OSSAsyncTask;
import com.alibaba.sdk.android.oss.model.PutObjectRequest;
import com.alibaba.sdk.android.oss.model.PutObjectResult;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.bigkoo.pickerview.view.TimePickerView;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.luck.picture.lib.basic.PictureSelector;
import com.luck.picture.lib.config.SelectMimeType;
import com.luck.picture.lib.config.SelectModeConfig;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.interfaces.OnResultCallbackListener;
import com.luoxiang.socialandroid.R;
import com.luoxiang.socialandroid.adapter.TextBqAdapter;
import com.luoxiang.socialandroid.app.MyAppliaction;
import com.luoxiang.socialandroid.base.BaseActivity;
import com.luoxiang.socialandroid.bean.AreaLibBean;
import com.luoxiang.socialandroid.bean.AreaLibToCity;
import com.luoxiang.socialandroid.bean.AuditinfoBean;
import com.luoxiang.socialandroid.bean.Children;
import com.luoxiang.socialandroid.bean.EmBean;
import com.luoxiang.socialandroid.bean.LableData;
import com.luoxiang.socialandroid.bean.NumberBean;
import com.luoxiang.socialandroid.bean.Poto;
import com.luoxiang.socialandroid.bean.ProBean;
import com.luoxiang.socialandroid.bean.ProLib;
import com.luoxiang.socialandroid.bean.TokenBean;
import com.luoxiang.socialandroid.bean.UserInfoBean;
import com.luoxiang.socialandroid.bean.UserinfoBeans;
import com.luoxiang.socialandroid.bean.UssBean;
import com.luoxiang.socialandroid.bean.UusLib;
import com.luoxiang.socialandroid.bean.EmLib;
import com.luoxiang.socialandroid.dialog.DetailsImageViewerPopup;
import com.luoxiang.socialandroid.dialog.TipDialog;
import com.luoxiang.socialandroid.utils.AESUtil;
import com.luoxiang.socialandroid.utils.CustomClickListener;
import com.luoxiang.socialandroid.utils.GlideEngine;
import com.luoxiang.socialandroid.utils.MmkvUtil;
import com.luoxiang.socialandroid.utils.NetUtils;
import com.luoxiang.socialandroid.utils.NetUtils2;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.util.SmartGlideImageLoader;

import com.wdl.gifmaker.GifTransform;
import com.wdl.gifmaker.OnTransformProgressListener;
import com.yalantis.ucrop.UCrop;
import com.yalantis.ucrop.UCropImageEngine;

import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;

public class UserInfoActivity extends BaseActivity implements View.OnClickListener {
    private String token;
    private RelativeLayout r_name, r_birth, r_height, r_weight, r_city, r_job, r_love, r_uss;
    private ImageView icon_back, im_icon, im1_info, im2_info, im3_info, im4_info, im5_info, vedio_info, icon_shiping, img_toxiangyou, vedio_info1;
    private TextView tx_name, tx_birth, tx_sex, tx_tel, tx_height, tx_weight, tx_city, tx_job, tx_love, tx_uss, xingxiang, textSignatureSize, textLabelLength, textTip;
    private Button bt_finish, icon_clear1, icon_clear2, icon_clear3, icon_clear4, icon_clear5, icon_clear6;
    private ConstraintLayout constraintWeChat;
    private EditText editWeChat;
    private String url = "https://dahuixiong.oss-cn-shenzhen.aliyuncs.com/";
    private int leixing;
    private String video, pathsvideo, pathsfirst;
    private String paths, mineViediopath, minegifpath;
    private EditText tx_geqian;
    private String usericon;
    private String iconlist;
    private int adCode;
    private int proid, emId;
    private RecyclerView rc_xx;
    private TextBqAdapter adapter;
    private List<String> data = new ArrayList<>();
    private List<String> selectIdList = new ArrayList<>();
    private String Htvidiepath, Htvgifpath;
    private String labelsid;
    private String HtreturnVideo;
    private String userbeginlist;
    private int ussid;
    private Button icon_clear7;
    private String absolutePath;
    private HashMap<Integer, Poto> potoHashMap = new HashMap<>();
    private boolean tokenVideoBlock = false;
    private TextView textHaveTo;
    RoundedCorners roundedCorners = new RoundedCorners(30);
    RequestOptions options1 = RequestOptions.bitmapTransform(roundedCorners);
    RequestOptions options = new RequestOptions()
            .placeholder(R.mipmap.icon_error_img2)//图片加载出来前，显示的图片
            .fallback(R.mipmap.icon_error_img2) //url为空的时候,显示的图片
            .error(R.mipmap.icon_error_img2);//图片加载失败后，显示的图片

    @Override
    protected void initListener() {
        icon_clear7.setOnClickListener(new CustomClickListener() {
            @Override
            protected void onSingleClick() {
                vedio_info1.setVisibility(View.GONE);
                vedio_info.setVisibility(View.VISIBLE);
                icon_clear7.setVisibility(View.GONE);
                icon_shiping.setVisibility(View.GONE);
                Htvidiepath = null;
                Htvgifpath = null;
                mineViediopath = null;
            }

            @Override
            protected void onFastClick() {

            }
        });
        icon_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        r_name.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(UserInfoActivity.this, RenameActivity.class);
                intent.putExtra("name", tx_name.getText());
                startActivity(intent);
            }
        });

        r_birth.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showTimePicker();
            }
        });
//        r_sex.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                initSelector();
//            }
//        });
        r_height.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                heightSelector();
            }
        });
        r_weight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                weightSelector();
            }
        });
        r_city.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                citySelector(token, EXTRA);
            }
        });
        r_job.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                jobSelector(token, EXTRA);
            }
        });
        r_love.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                loveSelector(token, EXTRA);
            }
        });
        r_uss.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ussSelector(token, EXTRA);
            }
        });
        xingxiang.setOnClickListener(new CustomClickListener() {
            @Override
            protected void onSingleClick() {
                Intent intent = new Intent(UserInfoActivity.this, LableActivity.class);
                startActivityForResult(intent, 3);
            }

            @Override
            protected void onFastClick() {

            }
        });
        img_toxiangyou.setOnClickListener(new CustomClickListener() {
            @Override
            protected void onSingleClick() {
                Intent intent = new Intent(UserInfoActivity.this, LableActivity.class);
                startActivityForResult(intent, 3);
            }

            @Override
            protected void onFastClick() {

            }
        });
        textTip.setOnClickListener(v -> {
            Intent intent = new Intent(UserInfoActivity.this, LableActivity.class);
            startActivityForResult(intent, 3);
        });
        bt_finish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Gson gson = new Gson();
                iconlist = gson.toJson(potoHashMap.values());
                if (mineViediopath != null) {
                    Htvidiepath = mineViediopath;
                    Htvgifpath = minegifpath;

                } else {
                    Htvidiepath = HtreturnVideo;

                }

                if (paths != null) {
                    if (leixing == 1) {
                        if (iconlist != null) {
                            tofinish(token, EXTRA, leixing, "", paths, iconlist, Htvidiepath, Htvgifpath);

                        } else {
                            tofinish(token, EXTRA, leixing, "", paths, userbeginlist, Htvidiepath, Htvgifpath);
                        }
                    } else {
                        if (iconlist != null) {
                            tofinish(token, EXTRA, leixing, pathsvideo, paths, iconlist, Htvidiepath, Htvgifpath);
                        } else {
                            tofinish(token, EXTRA, leixing, pathsvideo, paths, userbeginlist, Htvidiepath, Htvgifpath);

                        }
                    }
                } else {
                    if (leixing == 1) {
                        if (iconlist != null) {
                            tofinish(token, EXTRA, leixing, "", usericon, iconlist, Htvidiepath, Htvgifpath);

                        } else {
                            tofinish(token, EXTRA, leixing, "", usericon, userbeginlist, Htvidiepath, Htvgifpath);
                        }
                    } else {
                        if (iconlist != null) {
                            tofinish(token, EXTRA, leixing, pathsvideo, usericon, iconlist, Htvidiepath, Htvgifpath);
                        } else {
                            tofinish(token, EXTRA, leixing, pathsvideo, usericon, userbeginlist, Htvidiepath, Htvgifpath);
                        }

                    }

                }
            }
        });
        vedio_info.setOnClickListener(v -> {
            //点击视频
            getPicturevideo();
        });

        tx_geqian.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                textSignatureSize.setText(s.length() + "/30");
            }

            @Override
            public void afterTextChanged(Editable s) {
            }
        });

    }

    private void getPicturevideo() {

        PictureSelector.create(this)
                .openGallery(SelectMimeType.ofVideo())
                .setImageEngine(GlideEngine.createGlideEngine())
                .setCropEngine((fragment, srcUri, destinationUri, dataSource, requestCode) -> {
                    // 注意* 如果你实现自己的裁剪库，需要在Activity的.setResult();
                    // Intent中需要给MediaStore.EXTRA_OUTPUT，塞入裁剪后的路径；如果有额外数据也可以通过CustomIntentKey.EXTRA_CUSTOM_EXTRA_DATA字段存入；
                    UCrop uCrop = UCrop.of(srcUri, destinationUri, dataSource);
                    uCrop.setImageEngine(new UCropImageEngine() {
                        @Override
                        public void loadImage(Context context, String url, ImageView imageView) {
                            Glide.with(context)
                                    .load(url)
                                    .transform(new CenterCrop())
                                    .into(imageView);
                        }

                        @Override
                        public void loadImage(Context context, Uri url, int maxWidth, int maxHeight, OnCallbackListener<Bitmap> call) {
                            Glide.with(context)
                                    .asBitmap().override(maxWidth, maxHeight).load(url)
                                    .transform(new CenterCrop())
                                    .into(new CustomTarget<Bitmap>() {
                                        @Override
                                        public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                                            if (call != null) {
                                                call.onCall(resource);
                                            }
                                        }

                                        @Override
                                        public void onLoadFailed(@Nullable Drawable errorDrawable) {
                                            if (call != null) {
                                                call.onCall(null);
                                            }
                                        }

                                        @Override
                                        public void onLoadCleared(@Nullable Drawable placeholder) {
                                        }
                                    });
                        }
                    });
                    uCrop.start(fragment.requireActivity(), fragment, requestCode);
                })
                .forResult(new OnResultCallbackListener<LocalMedia>() {
                    @Override
                    public void onResult(ArrayList<LocalMedia> result) {
                        if (result.isEmpty()) {
                            return;
                        } else {
                            String realPath = result.get(0).getRealPath();

                            if (result.get(0).getPath() != null) {
                                Glide.with(UserInfoActivity.this)
                                        .asBitmap()
                                        .load(result.get(0).getPath())
                                        .override(300, 300)
                                        .transform(new CenterCrop(), new RoundedCorners(8))
                                        .placeholder(com.luck.picture.lib.R.drawable.ps_image_placeholder)
                                        .into(vedio_info1);
                                vedio_info.setVisibility(View.GONE);
                                vedio_info1.setVisibility(View.VISIBLE);


                            } else {
                                Glide.with(UserInfoActivity.this)
                                        .asBitmap()
                                        .load(result.get(0).getRealPath())
                                        .transform(new CenterCrop(), new RoundedCorners(30))
                                        .placeholder(com.luck.picture.lib.R.drawable.ps_image_placeholder)
                                        .into(vedio_info1);
                                vedio_info.setVisibility(View.GONE);
                                vedio_info1.setVisibility(View.VISIBLE);
                            }

                            vedio_info1.setOnClickListener(new CustomClickListener() {
                                @Override
                                protected void onSingleClick() {
                                    Intent intent = new Intent(UserInfoActivity.this, SeevideoActivity.class);
                                    intent.putExtra("pathvideo", result.get(0).getRealPath());
                                    startActivity(intent);
                                }

                                @Override
                                protected void onFastClick() {

                                }
                            });

                            mineViediopath = getkey(realPath);
                            GifTransform transform = new GifTransform(getApplicationContext().getCacheDir() + "/gif.gif");
                            transform.setQuality(80);
                            transform.setScaleX(1);
                            transform.setScaleY(2);
                            transform.setOnTransformProgressListener(new OnTransformProgressListener() {
                                @Override
                                public void onProgress(int current, int total) {
                                    Log.e(TAG, "current : " + current);
                                }
                            });
                            final boolean resultgif = transform.transformFromVideo(realPath, 0, 5 * 1000, 250);
                            if (resultgif) {
                                //在这里取
                                File file = new File(getApplicationContext().getCacheDir() + "/gif.gif");
                                absolutePath = file.getAbsolutePath();
                                LogUtils.i("absoluteFile", absolutePath);
                                minegifpath = getkey(absolutePath);
                                getTokenMineGif(absolutePath);
                            }
                            if (mineViediopath != null) {
                                icon_clear7.setVisibility(View.VISIBLE);
                            } else {
                                icon_clear7.setVisibility(View.GONE);
                            }

                            getTokenMineVideo(realPath);
                        }
                    }

                    @Override
                    public void onCancel() {

                    }
                });

    }


    public void getTokenvideo(String picturePaths) {
        tokenVideoBlock = true;
        getRequest();
        NetUtils2.getInstance().getApiService().getUploadToken()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<NumberBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(NumberBean numberBean) {
                        String data = numberBean.getData();
                        String decryptStr = null;
                        try {
                            decryptStr = AESUtil.aesDecryptString(data, KEY);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        try {
                            LogUtils.i("decryptStrpp", decryptStr);
                            Gson gson = new Gson();
                            TokenBean tokenBean = gson.fromJson(decryptStr, TokenBean.class);
                            if (tokenBean != null) {
                                String endpoint = tokenBean.getData().getSts().getEndpoint();

                                // 在移动端建议使用STS的方式初始化OSSClient。
                                OSSCredentialProvider credentialProvider = new OSSStsTokenCredentialProvider(tokenBean.getData().getSts().getAccessKeyId(), tokenBean.getData().getSts().getAccessKeySecret(), tokenBean.getData().getSts().getSecurityToken());

                                ClientConfiguration conf = new ClientConfiguration();
                                conf.setConnectionTimeout(15 * 1000); // 连接超时，默认15秒。
                                conf.setSocketTimeout(15 * 1000); // socket超时，默认15秒。
                                conf.setMaxConcurrentRequest(5); // 最大并发请求书，默认5个。
                                conf.setMaxErrorRetry(2); // 失败后最大重试次数，默认2次。

                                OSS oss = new OSSClient(getApplicationContext(), endpoint, credentialProvider, conf);
//                                for (String localPath:picturePaths) {

                                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd/HHmmss/");
                                Date date = new Date(System.currentTimeMillis());
                                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                                //文件后缀   例如：.png
                                String fileType = picturePaths.substring(picturePaths.lastIndexOf("."));
//                                String path = "exampledir/exampleobject.txt";

                                LogUtils.i("pathiii", key);
                                // 构造上传请求。
//                                2022/09/29/191405/UUID.PNG
                                PutObjectRequest putObjectRequest = new PutObjectRequest(tokenBean.getData().getSts().getBucketName(), pathsvideo, picturePaths);

                                putObjectRequest.setProgressCallback(new OSSProgressCallback<PutObjectRequest>() {
                                    @Override
                                    public void onProgress(PutObjectRequest request, long currentSize, long totalSize) {
                                        LogUtils.d("进度为", "当前进度为:" + totalSize + "/" + currentSize);
                                    }
                                });
                                OSSAsyncTask ossAsyncTask = oss.asyncPutObject(putObjectRequest, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
                                    @Override
                                    public void onSuccess(PutObjectRequest request, PutObjectResult result) {
//                                        paths.add(path);
                                        tokenVideoBlock = false;
                                        LogUtils.d("aliossresult", "上传成功" + "diyi\t\t" + result.toString() + "\t\tdier=" + request.toString());
                                    }

                                    @Override
                                    public void onFailure(PutObjectRequest request, ClientException clientException, ServiceException serviceException) {
                                        tokenVideoBlock = false;
                                        LogUtils.d("aliossresult", "上传失败");
                                    }
                                });
                                ossAsyncTask.getResult();
//                            }
                                LogUtils.i("ossmin", oss.toString());
                            }

                        } catch (Exception e) {
                            tokenVideoBlock = false;
                        }
                    }

                    @Override
                    public void onError(Throwable e) {
                        tokenVideoBlock = false;
                    }

                    @Override
                    public void onComplete() {

                    }
                });

    }

    public void getTokenbyfirst(String picturePaths, String pathsfirstor) {

//        List<String> paths=new ArrayList<>();

        getRequest();
        NetUtils2.getInstance().getApiService().getUploadToken()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<NumberBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(NumberBean numberBean) {
                        String data = numberBean.getData();
                        String decryptStr = null;
                        try {
                            decryptStr = AESUtil.aesDecryptString(data, KEY);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        try {


                            LogUtils.i("decryptStrpp", decryptStr);
                            Gson gson = new Gson();
                            TokenBean tokenBean = gson.fromJson(decryptStr, TokenBean.class);
                            if (tokenBean != null) {
                                String endpoint = tokenBean.getData().getSts().getEndpoint();

                                // 在移动端建议使用STS的方式初始化OSSClient。
                                OSSCredentialProvider credentialProvider = new OSSStsTokenCredentialProvider(tokenBean.getData().getSts().getAccessKeyId(), tokenBean.getData().getSts().getAccessKeySecret(), tokenBean.getData().getSts().getSecurityToken());

                                ClientConfiguration conf = new ClientConfiguration();
                                conf.setConnectionTimeout(15 * 1000); // 连接超时，默认15秒。
                                conf.setSocketTimeout(15 * 1000); // socket超时，默认15秒。


                                conf.setMaxConcurrentRequest(5); // 最大并发请求书，默认5个。
                                conf.setMaxErrorRetry(2); // 失败后最大重试次数，默认2次。

                                OSS oss = new OSSClient(getApplicationContext(), endpoint, credentialProvider, conf);
//                                for (String localPath:picturePaths) {

                                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd/HHmmss/");
                                Date date = new Date(System.currentTimeMillis());
                                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                                //文件后缀   例如：.png
                                String fileType = picturePaths.substring(picturePaths.lastIndexOf("."));
//                                String path = "exampledir/exampleobject.txt";

                                LogUtils.i("pathiii", key);
                                // 构造上传请求。
//                                2022/09/29/191405/UUID.PNG
                                PutObjectRequest putObjectRequest = new PutObjectRequest(tokenBean.getData().getSts().getBucketName(), pathsfirstor, picturePaths);

                                putObjectRequest.setProgressCallback(new OSSProgressCallback<PutObjectRequest>() {
                                    @Override
                                    public void onProgress(PutObjectRequest request, long currentSize, long totalSize) {

                                    }
                                });
                                OSSAsyncTask ossAsyncTask = oss.asyncPutObject(putObjectRequest, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
                                    @Override
                                    public void onSuccess(PutObjectRequest request, PutObjectResult result) {
//                                        paths.add(path);
                                        LogUtils.d("aliossresult", "上传成功" + "diyi\t\t" + result.toString() + "\t\tdier=" + request.toString());
                                    }

                                    @Override
                                    public void onFailure(PutObjectRequest request, ClientException clientException, ServiceException serviceException) {
                                        LogUtils.d("aliossresult", "上传失败");

                                    }
                                });
//                            }
                                LogUtils.i("ossmin", oss.toString());
                            }

                        } catch (Exception e) {
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

    }

    public void getTokenMineGif(String picturePaths) {

//        List<String> paths=new ArrayList<>();

        getRequest();
        NetUtils2.getInstance().getApiService().getUploadToken()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<NumberBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(NumberBean numberBean) {
                        String data = numberBean.getData();
                        String decryptStr = null;
                        try {
                            decryptStr = AESUtil.aesDecryptString(data, KEY);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        try {


                            LogUtils.i("decryptStrpp", decryptStr);
                            Gson gson = new Gson();
                            TokenBean tokenBean = gson.fromJson(decryptStr, TokenBean.class);
                            if (tokenBean != null) {
                                String endpoint = tokenBean.getData().getSts().getEndpoint();

                                // 在移动端建议使用STS的方式初始化OSSClient。
                                OSSCredentialProvider credentialProvider = new OSSStsTokenCredentialProvider(tokenBean.getData().getSts().getAccessKeyId(), tokenBean.getData().getSts().getAccessKeySecret(), tokenBean.getData().getSts().getSecurityToken());

                                ClientConfiguration conf = new ClientConfiguration();
                                conf.setConnectionTimeout(15 * 1000); // 连接超时，默认15秒。
                                conf.setSocketTimeout(15 * 1000); // socket超时，默认15秒。


                                conf.setMaxConcurrentRequest(5); // 最大并发请求书，默认5个。
                                conf.setMaxErrorRetry(2); // 失败后最大重试次数，默认2次。

                                OSS oss = new OSSClient(getApplicationContext(), endpoint, credentialProvider, conf);
//                                for (String localPath:picturePaths) {
                                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd/HHmmss/");
                                Date date = new Date(System.currentTimeMillis());
                                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                                //文件后缀   例如：.png
                                String fileType = picturePaths.substring(picturePaths.lastIndexOf("."));
//                                String path = "exampledir/exampleobject.txt";

                                LogUtils.i("pathiii", key);
                                // 构造上传请求。
//                                2022/09/29/191405/UUID.PNG
                                PutObjectRequest putObjectRequest = new PutObjectRequest(tokenBean.getData().getSts().getBucketName(), minegifpath, picturePaths);

                                putObjectRequest.setProgressCallback((request, currentSize, totalSize) ->
                                        LogUtils.d("上传进度", "进度为 --> :" + totalSize + "/" + currentSize)
                                );
                                OSSAsyncTask ossAsyncTask = oss.asyncPutObject(putObjectRequest, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
                                    @Override
                                    public void onSuccess(PutObjectRequest request, PutObjectResult result) {
//                                        paths.add(path);
                                        LogUtils.d("aliossresult", "上传成功" + "diyi\t\t" + result.toString() + "\t\tdier=" + request.toString());
                                    }

                                    @Override
                                    public void onFailure(PutObjectRequest request, ClientException clientException, ServiceException serviceException) {
                                        LogUtils.d("aliossresult", "上传失败");
                                    }
                                });
                                ossAsyncTask.getResult();
//                            }
                                LogUtils.i("ossmin", oss.toString());
                            }

                        } catch (Exception e) {
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

    }

    public void getTokenMineVideo(String picturePaths) {

//        List<String> paths=new ArrayList<>();

        getRequest();
        NetUtils2.getInstance().getApiService().getUploadToken()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<NumberBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(NumberBean numberBean) {
                        String data = numberBean.getData();
                        String decryptStr = null;
                        try {
                            decryptStr = AESUtil.aesDecryptString(data, KEY);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        try {


                            LogUtils.i("decryptStrpp", decryptStr);
                            Gson gson = new Gson();
                            TokenBean tokenBean = gson.fromJson(decryptStr, TokenBean.class);
                            if (tokenBean != null) {
                                String endpoint = tokenBean.getData().getSts().getEndpoint();

                                // 在移动端建议使用STS的方式初始化OSSClient。
                                OSSCredentialProvider credentialProvider = new
                                        OSSStsTokenCredentialProvider(tokenBean.getData().getSts()
                                        .getAccessKeyId(), tokenBean.getData().getSts()
                                        .getAccessKeySecret(), tokenBean.getData().getSts()
                                        .getSecurityToken());

                                ClientConfiguration conf = new ClientConfiguration();
                                conf.setConnectionTimeout(15 * 1000); // 连接超时，默认15秒。
                                conf.setSocketTimeout(15 * 1000); // socket超时，默认15秒。


                                conf.setMaxConcurrentRequest(5); // 最大并发请求书，默认5个。
                                conf.setMaxErrorRetry(2); // 失败后最大重试次数，默认2次。

                                OSS oss = new OSSClient(getApplicationContext(), endpoint, credentialProvider, conf);
//                                for (String localPath:picturePaths) {

                                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd/HHmmss/");
                                Date date = new Date(System.currentTimeMillis());
                                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                                //文件后缀   例如：.png
                                String fileType = picturePaths.substring(picturePaths.lastIndexOf("."));
//                                String path = "exampledir/exampleobject.txt";

                                LogUtils.i("pathiii", key);
                                // 构造上传请求。
//                                2022/09/29/191405/UUID.PNG
                                PutObjectRequest putObjectRequest = new PutObjectRequest(tokenBean.getData().getSts().getBucketName(), mineViediopath, picturePaths);

                                putObjectRequest.setProgressCallback(new OSSProgressCallback<PutObjectRequest>() {
                                    @Override
                                    public void onProgress(PutObjectRequest request, long currentSize, long totalSize) {

                                    }
                                });
                                OSSAsyncTask ossAsyncTask = oss.asyncPutObject(putObjectRequest, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
                                    @Override
                                    public void onSuccess(PutObjectRequest request, PutObjectResult result) {
//                                        paths.add(path);
                                        LogUtils.d("aliossresult", "上传成功" + "diyi\t\t" + result.toString() + "\t\tdier=" + request.toString());
                                    }

                                    @Override
                                    public void onFailure(PutObjectRequest request, ClientException clientException, ServiceException serviceException) {
                                        LogUtils.d("aliossresult", "上传失败");

                                    }
                                });
//                            }
                                LogUtils.i("ossmin", oss.toString());
                            }

                        } catch (Exception e) {
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

    }

    public void getToken(String picturePaths) {

//        List<String> paths=new ArrayList<>();

        getRequest();
        NetUtils2.getInstance().getApiService().getUploadToken()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<NumberBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(NumberBean numberBean) {
                        String data = numberBean.getData();
                        String decryptStr = null;
                        try {
                            decryptStr = AESUtil.aesDecryptString(data, KEY);
                            LogUtils.i("decryptStrpp", decryptStr);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        try {


                            Gson gson = new Gson();
                            TokenBean tokenBean = gson.fromJson(decryptStr, TokenBean.class);
                            if (tokenBean != null) {
                                String endpoint = tokenBean.getData().getSts().getEndpoint();

                                // 在移动端建议使用STS的方式初始化OSSClient。
                                OSSCredentialProvider credentialProvider = new OSSStsTokenCredentialProvider(tokenBean.getData().getSts().getAccessKeyId(), tokenBean.getData().getSts().getAccessKeySecret(), tokenBean.getData().getSts().getSecurityToken());

                                ClientConfiguration conf = new ClientConfiguration();
                                conf.setConnectionTimeout(15 * 1000); // 连接超时，默认15秒。
                                conf.setSocketTimeout(15 * 1000); // socket超时，默认15秒。


                                conf.setMaxConcurrentRequest(5); // 最大并发请求书，默认5个。
                                conf.setMaxErrorRetry(2); // 失败后最大重试次数，默认2次。

                                OSS oss = new OSSClient(getApplicationContext(), endpoint, credentialProvider, conf);
//                                for (String localPath:picturePaths) {

                                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd/HHmmss/");
                                Date date = new Date(System.currentTimeMillis());
                                String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                                //文件后缀   例如：.png
                                String fileType = picturePaths.substring(picturePaths.lastIndexOf("."));
//                                String path = "exampledir/exampleobject.txt";

                                LogUtils.i("pathiii", key);
                                // 构造上传请求。
//                                2022/09/29/191405/UUID.PNG
                                PutObjectRequest putObjectRequest = new PutObjectRequest(tokenBean.getData().getSts().getBucketName(), paths, picturePaths);

                                putObjectRequest.setProgressCallback(new OSSProgressCallback<PutObjectRequest>() {
                                    @Override
                                    public void onProgress(PutObjectRequest request, long currentSize, long totalSize) {

                                    }
                                });
                                OSSAsyncTask ossAsyncTask = oss.asyncPutObject(putObjectRequest, new OSSCompletedCallback<PutObjectRequest, PutObjectResult>() {
                                    @Override
                                    public void onSuccess(PutObjectRequest request, PutObjectResult result) {
//                                        paths.add(path);
                                        LogUtils.d("aliossresult", "上传成功" + "diyi\t\t" + result.toString() + "\t\tdier=" + request.toString());
                                    }

                                    @Override
                                    public void onFailure(PutObjectRequest request, ClientException clientException, ServiceException serviceException) {
                                        LogUtils.d("aliossresult", "上传失败");

                                    }
                                });
//                            }
                                LogUtils.i("ossmin", oss.toString());
                            }

                        } catch (Exception e) {
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });

    }

    //    @Field("token")
//    @Field("extra")
//    @Field("type")
//    @Field("name")
//    @Field("phone")
//    @Field("height")
//    @Field("weight")
//    @Field("ussId")
//    @Field("cityCode")
//    @Field("lables")
//    @Field("persionSign")
//    @Field("icon")
//    @Field("birthday")
//    @Field("gender")
//    @Field("proId")
//    @Field("emId")
    private void tofinish(String token, String extra, int i, String video, String paths, String iconlist, String persionVideo, String persionGif) {
        if (tokenVideoBlock) {
            toast("资源正在上传中，请稍等");
            return;
        }
        getRequest();
        String name = tx_name.getText().toString();
        String tel = tx_tel.getText().toString();
        String height = tx_height.getText().toString();
        String weight = tx_weight.getText().toString();
        String birth = tx_birth.getText().toString();
        String persionSign = tx_geqian.getText().toString();
        String weChatNumber = editWeChat.getText().toString().trim();

        if (height.isEmpty()) {
            Toast.makeText(this, R.string.mi_qingxuanzeshenggao, Toast.LENGTH_SHORT).show();
            return;
        }
        if (weight.isEmpty()) {
            Toast.makeText(this, R.string.mi_qingxuanzetizhong, Toast.LENGTH_SHORT).show();
            return;
        }
        if (birth.isEmpty()) {
            Toast.makeText(this, R.string.mi_qingxuanzeshengri, Toast.LENGTH_SHORT).show();
            return;
        }
        if (persionSign.isEmpty()) {
            Toast.makeText(this, R.string.mi_qingtianxieqianming, Toast.LENGTH_SHORT).show();
            return;
        }
        if (leixing == 0 && weChatNumber.isEmpty()) {
            Toast.makeText(this, R.string.mi_qingtianxieweixinghao, Toast.LENGTH_SHORT).show();
            return;
        }
        String weights = weight.substring(0, weight.indexOf("k"));
        String heights = height.substring(0, height.indexOf("c"));
        String sex = "";
        if (tx_sex.getText().toString().equals(getString(R.string.mi_nan))) {
            sex = "1";
        } else if (tx_sex.getText().toString().equals(getString(R.string.mi_nv))) {
            sex = "0";
        }
        if (selectIdList.isEmpty()) {
            ToastUtils.showShort(R.string.mi_qingxuanzebiaoqian);
            return;
        } else {
            labelsid = selectIdList.toString();
        }
        showLoading();
        NetUtils2.getInstance().getApiService().saveAuditInfo(token, extra, i, video, iconlist, name, tel, heights, weights, ussid + "", adCode + "", labelsid, persionSign, paths, birth, sex, proid + "", emId + "", persionVideo, persionGif, weChatNumber)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<NumberBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {}

                    @Override
                    public void onNext(NumberBean numberBean) {
                        clearLoading();
                        String data = numberBean.getData();
                        String decryptStr = null;
                        try {
                            decryptStr = AESUtil.aesDecryptString(data, KEY);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        LogUtils.i("decryptStrinfo", decryptStr);
                        Gson gson = new Gson();
                        UserinfoBeans userinfoData = gson.fromJson(decryptStr, UserinfoBeans.class);
                        if (userinfoData.getCode() == 0) {
                            ToastUtils.showShort(R.string.mi_ziliaoyitijiaoshenhe);
                            finish();
                        } else {
                            ToastUtils.showShort("提交失败" + userinfoData.getMsg());
                        }
                    }

                    @Override
                    public void onError(Throwable e) {
                        if (e.getMessage() != null) {
                            ToastUtils.showShort("提交失败" + e.getMessage());
                        }
                        clearLoading();
                    }

                    @Override
                    public void onComplete() {}
                });
    }


    private void ussSelector(String token, String extra) {
        NetUtils2.getInstance().getApiService().getUSSLib(token, extra)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<NumberBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(NumberBean numberBean) {
                        String data = numberBean.getData();
                        String decryptStr = null;
                        try {
                            decryptStr = AESUtil.aesDecryptString(data, KEY);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        LogUtils.i("decryptStr44", decryptStr);
                        Gson gson = new Gson();
                        UssBean bean = gson.fromJson(decryptStr, UssBean.class);

                        ArrayList<String> strings = new ArrayList<>();
                        ArrayList<String> ids = new ArrayList<>();
                        if (bean != null) {
                            if (bean.getData() != null) {
                                List<UusLib> lib = bean.getData().getUusLib();
                                for (int i = 0; i < lib.size(); i++) {
                                    strings.add(lib.get(i).getName() + "");
                                    ids.add(lib.get(i).getId() + "");
                                }
                                OptionsPickerView pvOptions = new OptionsPickerBuilder(UserInfoActivity.this, new OnOptionsSelectListener() {
                                    @Override
                                    public void onOptionsSelect(int options1, int option2, int options3, View v) {
                                        //返回的分别是三个级别的选中位置
                                        String tx = strings.get(options1);
                                        tx_uss.setText(tx);
                                        ussid = lib.get(options1).getId();
                                    }
                                })
                                        .setCancelColor(Color.parseColor("#999999"))
                                        .setSubmitColor(Color.parseColor("#835DFF"))
                                        .build();
                                pvOptions.setPicker(strings);
                                String selectText = tx_uss.getText().toString();
                                for (int i = 0; i < strings.size(); i++) {
                                    if (selectText.equals(strings.get(i))) {
                                        pvOptions.setSelectOptions(i);
                                    }
                                }
                                pvOptions.show();
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

    private void loveSelector(String token, String extra) {
        NetUtils2.getInstance().getApiService().getEmLib(token, extra)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<NumberBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(NumberBean numberBean) {
                        String data = numberBean.getData();
                        String decryptStr = null;
                        try {
                            decryptStr = AESUtil.aesDecryptString(data, KEY);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        LogUtils.i("decryptStr44", decryptStr);
                        Gson gson = new Gson();
                        EmBean bean = gson.fromJson(decryptStr, EmBean.class);

                        ArrayList<String> strings = new ArrayList<>();
                        ArrayList<String> ids = new ArrayList<>();
                        if (bean != null) {
                            if (bean.getData() != null) {
                                List<EmLib> lib = bean.getData().getEmLib();
                                for (int i = 0; i < lib.size(); i++) {
                                    strings.add(lib.get(i).getName() + "");
                                    ids.add(lib.get(i).getId() + "");
                                }
                                OptionsPickerView pvOptions = new OptionsPickerBuilder(UserInfoActivity.this, new OnOptionsSelectListener() {
                                    @Override
                                    public void onOptionsSelect(int options1, int option2, int options3, View v) {
                                        //返回的分别是三个级别的选中位置
                                        String tx = strings.get(options1);
                                        tx_love.setText(tx);
                                        emId = lib.get(options1).getId();
                                    }
                                }).setSubmitColor(Color.parseColor("#835DFF"))
                                        .setCancelColor(Color.parseColor("#999999"))
                                        .build();
                                pvOptions.setPicker(strings);
                                String selectText = tx_love.getText().toString();
                                for (int i = 0; i < strings.size(); i++) {
                                    if (selectText.equals(strings.get(i))) {
                                        pvOptions.setSelectOptions(i);
                                    }
                                }

                                pvOptions.show();
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

    private void jobSelector(String token, String extra) {
        NetUtils2.getInstance().getApiService().getProLib(token, extra)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<NumberBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(NumberBean numberBean) {
                        String data = numberBean.getData();
                        String decryptStr = null;
                        try {
                            decryptStr = AESUtil.aesDecryptString(data, KEY);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        LogUtils.i("decryptStr44", decryptStr);
                        Gson gson = new Gson();
                        ProBean bean = gson.fromJson(decryptStr, ProBean.class);

                        ArrayList<String> strings = new ArrayList<>();
                        ArrayList<String> ids = new ArrayList<>();
                        if (bean != null) {
                            if (bean.getData() != null) {
                                List<ProLib> lib = bean.getData().getProLib();
                                for (int i = 0; i < lib.size(); i++) {
                                    strings.add(lib.get(i).getName() + "");
                                    ids.add(lib.get(i).getId() + "");
                                }
                                OptionsPickerView pvOptions = new OptionsPickerBuilder(UserInfoActivity.this, new OnOptionsSelectListener() {
                                    @Override
                                    public void onOptionsSelect(int options1, int option2, int options3, View v) {
                                        //返回的分别是三个级别的选中位置
                                        String tx = strings.get(options1);
                                        tx_job.setText(tx);
                                        proid = lib.get(options1).getId();
                                    }
                                })
                                        .setCancelColor(Color.parseColor("#999999"))
                                        .setSubmitColor(Color.parseColor("#835DFF"))
                                        .build();
                                pvOptions.setPicker(strings);
                                String selectText = tx_job.getText().toString();
                                for (int i = 0; i < strings.size(); i++) {
                                    if (selectText.equals(strings.get(i))) {
                                        pvOptions.setSelectOptions(i);
                                    }
                                }
                                pvOptions.show();
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

    private void citySelector(String token, String extra) {
        NetUtils2.getInstance().getApiService().getAreaLib(token, extra)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<NumberBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(NumberBean numberBean) {
                        String data = numberBean.getData();
                        String decryptStr = null;
                        try {
                            decryptStr = AESUtil.aesDecryptString(data, KEY);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        LogUtils.i("decryptStr42", decryptStr);
                        Gson gson = new Gson();
                        AreaLibBean bean = gson.fromJson(decryptStr, AreaLibBean.class);
                        ArrayList<String> listSheng = new ArrayList<>();
                        ArrayList<ArrayList<String>> listCity = new ArrayList<>();
                        for (AreaLibToCity areaLibToCity : bean.getData().getAreaLibToCity()) {
                            listSheng.add(areaLibToCity.getName());
                            ArrayList<String> citys = new ArrayList<>();
                            for (Children children : areaLibToCity.getChildrens()) {
                                citys.add(children.getName());
                            }
                            listCity.add(citys);
                        }

                        OptionsPickerView pvOptions = new OptionsPickerBuilder(UserInfoActivity.this, new OnOptionsSelectListener() {
                            @Override
                            public void onOptionsSelect(int options1, int option2, int options3, View v) {
                                //返回的分别是三个级别的选中位置
                                String tx = bean.getData().getAreaLibToCity().get(options1).getName();
                                String name = bean.getData().getAreaLibToCity().get(options1).getChildrens().get(option2).getName();
                                adCode = bean.getData().getAreaLibToCity().get(options1).getAdCode();
                                tx_city.setText(name);
                            }
                        })
                                .setSubmitColor(Color.parseColor("#835DFF"))
                                .setCancelColor(Color.parseColor("#999999"))
                                .build();
                        pvOptions.setPicker(listSheng, listCity);
                        String selectText = tx_city.getText().toString();
                        for (int i = 0; i < listCity.size(); i++) {
                            ArrayList<String> strings = listCity.get(i);
                            for (int j = 0; j < strings.size(); j++) {
                                String s = strings.get(j);
                                if (s.equals(selectText)) {
                                    pvOptions.setSelectOptions(i, j);
                                }
                            }
                        }
                        pvOptions.show();
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

    private void weightSelector() {
        ArrayList<String> options1Items = new ArrayList<>();
        for (int i = 30; i <= 200; i++) {
            options1Items.add(i + "kg");
        }
        OptionsPickerView pvOptions = new OptionsPickerBuilder(UserInfoActivity.this, new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3, View v) {
                //返回的分别是三个级别的选中位置
                String tx = options1Items.get(options1);
                tx_weight.setText(tx);
            }
        })
                .setCancelColor(Color.parseColor("#999999"))
                .setSubmitColor(Color.parseColor("#835DFF"))
                .build();
        pvOptions.setPicker(options1Items);
        pvOptions.setSelectOptions(30);
        String selectText = tx_weight.getText().toString();
        for (int i = 0; i < options1Items.size(); i++) {
            if (selectText.equals(options1Items.get(i))) {
                pvOptions.setSelectOptions(i);
            }
        }
        pvOptions.show();
    }

    private void heightSelector() {
        ArrayList<String> options1Items = new ArrayList<>();
        for (int i = 50; i < 250; i++) {
            options1Items.add(i + "cm");
        }
        OptionsPickerView pvOptions = new OptionsPickerBuilder(UserInfoActivity.this, new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3, View v) {
                //返回的分别是三个级别的选中位置
                String tx = options1Items.get(options1);
                tx_height.setText(tx);
            }
        })
                .setCancelColor(Color.parseColor("#999999"))
                .setSubmitColor(Color.parseColor("#835DFF"))
                .build();
        pvOptions.setPicker(options1Items);
        pvOptions.setSelectOptions(110);
        String selectText = tx_height.getText().toString();
        for (int i = 0; i < options1Items.size(); i++) {
            if (selectText.equals(options1Items.get(i))) {
                pvOptions.setSelectOptions(i);
            }
        }
        pvOptions.show();
    }

    private void showTimePicker() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        //时间选择器
        TimePickerView pvTime = new TimePickerBuilder(this, new OnTimeSelectListener() {
            @Override
            public void onTimeSelect(Date date, View v) {
                //LogUtils.v(TimeUtil.dateToString(date));

                String format = simpleDateFormat.format(date.getTime());
                tx_birth.setText(format);
            }
        })
                .setCancelColor(Color.parseColor("#999999"))
                .setSubmitColor(Color.parseColor("#835DFF"))
                .build();
        String s = tx_birth.getText().toString();
        if (!StringUtils.isEmpty(s)) {
            try {
                Date parse = simpleDateFormat.parse(s);
                Calendar cal = Calendar.getInstance();
                cal.setTime(parse);
                pvTime.setDate(cal);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        pvTime.show();
    }

    @Override
    protected void initLayout(Bundle savedInstanceState) {
        setContentView(R.layout.activity_userinfo);
        setStatusBarTranslucent();
    }

    @Override
    protected void initView() {
        showLoading();
        token = MmkvUtil.INSTANCE.decodeString(TOKEN);
        getRequest();
        getAuditInfo(EXTRA, token);
        Intent intent = getIntent();
        leixing = intent.getIntExtra("leixing", 1);
        video = intent.getStringExtra("video");
        if (video != null) {
            pathsvideo = intent.getStringExtra("videoPath");
        }
        constraintWeChat = findViewById(R.id.constraintWeChat);
        editWeChat = findViewById(R.id.editWeChat);
        im_icon = findViewById(R.id.im_icon);
        im_icon.setOnClickListener(this);
        im1_info = findViewById(R.id.im1_info);
        textHaveTo = findViewById(R.id.textHaveTo);
        im1_info.setOnClickListener(this);
        im2_info = findViewById(R.id.im2_info);
        im2_info.setOnClickListener(this);
        im3_info = findViewById(R.id.im3_info);
        im3_info.setOnClickListener(this);
        im4_info = findViewById(R.id.im4_info);
        im4_info.setOnClickListener(this);
        im5_info = findViewById(R.id.im5_info);
        im5_info.setOnClickListener(this);
        vedio_info = findViewById(R.id.vedio_info);
        vedio_info1 = findViewById(R.id.vedio_info1);
        icon_shiping = findViewById(R.id.icon_shiping);
        icon_back = findViewById(R.id.icon_back);
        tx_name = findViewById(R.id.tx_name);
        r_name = findViewById(R.id.r_name);
        r_birth = findViewById(R.id.r_birth);
        r_height = findViewById(R.id.r_height);
        icon_clear7 = findViewById(R.id.icon_clear7);
        img_toxiangyou = findViewById(R.id.img_toxiangyou);
        r_weight = findViewById(R.id.r_weight);
        r_city = findViewById(R.id.r_city);
        r_job = findViewById(R.id.r_job);
        r_love = findViewById(R.id.r_love);
        r_uss = findViewById(R.id.r_uss);
        tx_tel = findViewById(R.id.tx_tel);
        tx_sex = findViewById(R.id.tx_sex);
        tx_birth = findViewById(R.id.tx_birth);
        tx_geqian = findViewById(R.id.tx_geqian);
        tx_height = findViewById(R.id.tx_height);
        tx_weight = findViewById(R.id.tx_weight);
        tx_city = findViewById(R.id.tx_city);
        tx_job = findViewById(R.id.tx_job);
        tx_love = findViewById(R.id.tx_love);
        tx_uss = findViewById(R.id.tx_uss);
        xingxiang = findViewById(R.id.xingxiang);
        bt_finish = findViewById(R.id.bt_finish);
        rc_xx = findViewById(R.id.rc_xx);
        textLabelLength = findViewById(R.id.textLabelLength);
        textSignatureSize = findViewById(R.id.textSignatureSize);
        textTip = findViewById(R.id.textTip);
        icon_clear1 = findViewById(R.id.icon_clear1);
        icon_clear2 = findViewById(R.id.icon_clear2);
        icon_clear3 = findViewById(R.id.icon_clear3);
        icon_clear4 = findViewById(R.id.icon_clear4);
        icon_clear5 = findViewById(R.id.icon_clear5);
        icon_clear6 = findViewById(R.id.icon_clear6);
        getMineUserInfo(token, EXTRA);
        adapter = new TextBqAdapter(data);
        rc_xx.setAdapter(adapter);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(UserInfoActivity.this, RecyclerView.HORIZONTAL, false);
        rc_xx.setLayoutManager(linearLayoutManager);

       if (leixing == 0) {
            constraintWeChat.setVisibility(View.VISIBLE);
        } else {
            if (com.luoxiang.lib_common.utils.MmkvUtil.INSTANCE.decodeInt(HOSTAUDIT).equals(1)) {
                constraintWeChat.setVisibility(View.VISIBLE);
            }else{
                constraintWeChat.setVisibility(View.GONE);
            }
        }

        icon_clear2.setOnClickListener(v -> {
            TipDialog tipDialog = new TipDialog(UserInfoActivity.this);
            tipDialog.setTitle(getString(R.string.mi_caozuotishi));
            tipDialog.setCancel(getString(R.string.mi_quxiao));
            tipDialog.setContent(getString(R.string.mi_ninquedingshanchugaizhaopian));
            tipDialog.setConfirm(getString(R.string.mi_queding));
            tipDialog.setOnCancelClickListener(new Function0<Unit>() {
                @Override
                public Unit invoke() {
                    tipDialog.dismiss();
                    return null;
                }
            });
            tipDialog.setOnConfirmClickListener(new Function0<Unit>() {
                @Override
                public Unit invoke() {
                    potoHashMap.remove(2);
                    im1_info.setImageDrawable(ContextCompat.getDrawable(UserInfoActivity.this, R.mipmap.icon_add2));
                    icon_clear2.setVisibility(View.GONE);
                    tipDialog.dismiss();
                    return null;
                }
            });
            new XPopup.Builder(UserInfoActivity.this)
                    .asCustom(tipDialog)
                    .show();

        });
        icon_clear3.setOnClickListener(v -> {
            TipDialog tipDialog = new TipDialog(UserInfoActivity.this);
            tipDialog.setTitle(getString(R.string.mi_caozuotishi));
            tipDialog.setCancel(getString(R.string.mi_quxiao));
            tipDialog.setContent(getString(R.string.mi_ninquedingshanchugaizhaopian));
            tipDialog.setConfirm(getString(R.string.mi_queding));
            tipDialog.setOnCancelClickListener(new Function0<Unit>() {
                @Override
                public Unit invoke() {
                    tipDialog.dismiss();
                    return null;
                }
            });
            tipDialog.setOnConfirmClickListener(new Function0<Unit>() {
                @Override
                public Unit invoke() {
                    potoHashMap.remove(3);
                    im2_info.setImageDrawable(ContextCompat.getDrawable(UserInfoActivity.this, R.mipmap.icon_add2));
                    icon_clear3.setVisibility(View.GONE);
                    tipDialog.dismiss();
                    return null;
                }
            });
            new XPopup.Builder(UserInfoActivity.this)
                    .asCustom(tipDialog)
                    .show();

        });
        icon_clear4.setOnClickListener(v -> {
            TipDialog tipDialog = new TipDialog(UserInfoActivity.this);
            tipDialog.setTitle(getString(R.string.mi_caozuotishi));
            tipDialog.setCancel(getString(R.string.mi_quxiao));
            tipDialog.setContent(getString(R.string.mi_ninquedingshanchugaizhaopian));
            tipDialog.setConfirm(getString(R.string.mi_queding));
            tipDialog.setOnCancelClickListener(new Function0<Unit>() {
                @Override
                public Unit invoke() {
                    tipDialog.dismiss();
                    return null;
                }
            });
            tipDialog.setOnConfirmClickListener(new Function0<Unit>() {
                @Override
                public Unit invoke() {
                    potoHashMap.remove(4);
                    im3_info.setImageDrawable(ContextCompat.getDrawable(UserInfoActivity.this, R.mipmap.icon_add2));
                    icon_clear4.setVisibility(View.GONE);
                    tipDialog.dismiss();
                    return null;
                }
            });
            new XPopup.Builder(UserInfoActivity.this)
                    .asCustom(tipDialog)
                    .show();

        });
        icon_clear5.setOnClickListener(v -> {
            TipDialog tipDialog = new TipDialog(UserInfoActivity.this);
            tipDialog.setTitle(getString(R.string.mi_caozuotishi));
            tipDialog.setCancel(getString(R.string.mi_quxiao));
            tipDialog.setContent(getString(R.string.mi_ninquedingshanchugaizhaopian));
            tipDialog.setConfirm(getString(R.string.mi_queding));
            tipDialog.setOnCancelClickListener(new Function0<Unit>() {
                @Override
                public Unit invoke() {
                    tipDialog.dismiss();
                    return null;
                }
            });
            tipDialog.setOnConfirmClickListener(new Function0<Unit>() {
                @Override
                public Unit invoke() {
                    potoHashMap.remove(5);
                    im4_info.setImageDrawable(ContextCompat.getDrawable(UserInfoActivity.this, R.mipmap.icon_add2));
                    icon_clear5.setVisibility(View.GONE);
                    tipDialog.dismiss();
                    return null;
                }
            });
            new XPopup.Builder(UserInfoActivity.this)
                    .asCustom(tipDialog)
                    .show();

        });
        icon_clear6.setOnClickListener(v -> {
            TipDialog tipDialog = new TipDialog(UserInfoActivity.this);
            tipDialog.setTitle(getString(R.string.mi_caozuotishi));
            tipDialog.setCancel(getString(R.string.mi_quxiao));
            tipDialog.setContent(getString(R.string.mi_ninquedingshanchugaizhaopian));
            tipDialog.setConfirm(getString(R.string.mi_queding));
            tipDialog.setOnCancelClickListener(new Function0<Unit>() {
                @Override
                public Unit invoke() {
                    tipDialog.dismiss();
                    return null;
                }
            });
            tipDialog.setOnConfirmClickListener(new Function0<Unit>() {
                @Override
                public Unit invoke() {
                    potoHashMap.remove(6);
                    im5_info.setImageDrawable(ContextCompat.getDrawable(UserInfoActivity.this, R.mipmap.icon_add2));
                    icon_clear6.setVisibility(View.GONE);
                    tipDialog.dismiss();
                    return null;
                }
            });
            new XPopup.Builder(UserInfoActivity.this)
                    .asCustom(tipDialog)
                    .show();

        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            List<String> selectNameList = (List<String>) data.getSerializableExtra("selectName");
            selectIdList = (List<String>) data.getSerializableExtra("selectid");
            textLabelLength.setText(selectIdList.size() + "/3");
            if (selectNameList != null) {
                this.data.clear();
                this.data.addAll(selectNameList);
                if (selectIdList.size() == 0) {
                    textTip.setVisibility(View.VISIBLE);
                } else {
                    textTip.setVisibility(View.GONE);
                }
                adapter.notifyDataSetChanged();
            }
        }
    }

    private void getMineUserInfo(String token, String extra) {
        NetUtils2.getInstance().getApiService().getMineUserInfo(token, extra)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<NumberBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(NumberBean numberBean) {
                        String data = numberBean.getData();
                        String decryptStr = null;
                        try {
                            decryptStr = AESUtil.aesDecryptString(data, KEY);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        LogUtils.i("decryptStrq", decryptStr);
                        Gson gson = new Gson();
                        UserInfoBean bean = gson.fromJson(decryptStr, UserInfoBean.class);

                        if (bean != null) {
                            if (bean.getData() != null) {
                                if (bean.getData().getUser() != null) {
                                    usericon = bean.getData().getUser().getIcon();
                                    LogUtils.i("usericon", bean.getData().getUser().getIcon());
                                    tx_name.setText(bean.getData().getUser().getName());
                                    if (bean.getData().getUser().getBirthday() != null) {
                                        tx_birth.setText(bean.getData().getUser().getBirthday().substring(0, 10));
                                    }
                                    if (bean.getData().getUser().getGender() == 0) {
                                        tx_sex.setText(R.string.mi_nv);
                                    } else {
                                        tx_sex.setText(R.string.mi_nan);
                                    }
                                    tx_tel.setText(bean.getData().getUser().getPhone());
                                    if (bean.getData().getUser().getPersionSign() != null) {
                                        tx_geqian.setText(bean.getData().getUser().getPersionSign());
                                    }
                                    if (bean.getData().getUser().getHeight() != null) {
                                        tx_height.setText(bean.getData().getUser().getHeight() + "cm");
                                    }
                                    if (bean.getData().getUser().getWeight() != null) {
                                        tx_weight.setText(bean.getData().getUser().getWeight() + "kg");
                                    }
                                    if (bean.getData().getUser().getCity() != null) {
                                        tx_city.setText(bean.getData().getUser().getCity());
                                    }
                                    if (bean.getData().getUser().getPro() != null) {
                                        tx_job.setText(bean.getData().getUser().getPro());
                                    }
                                    if (bean.getData().getUser().getEm() != null) {
                                        tx_love.setText(bean.getData().getUser().getEm());
                                    }
                                    if (bean.getData().getUser().getUss() != null) {
                                        tx_uss.setText(bean.getData().getUser().getUss());
                                    }
                                    if (bean.getData().getUser().getLables() != null) {
                                        UserInfoActivity.this.data.clear();
                                        selectIdList.clear();
                                        for (LableData lable : bean.getData().getUser().getLables()) {
                                            UserInfoActivity.this.data.add(lable.getName());
                                            selectIdList.add(String.valueOf(lable.getId()));
                                            UserInfoActivity.this.adapter.notifyDataSetChanged();
                                        }
                                        textLabelLength.setText(selectIdList.size() + "/3");
                                        if (selectIdList.size() == 0) {
                                            textTip.setVisibility(View.VISIBLE);
                                        } else {
                                            textTip.setVisibility(View.GONE);
                                        }
                                        UserInfoActivity.this.adapter.notifyDataSetChanged();
                                    }
                                }
                            }
                        }
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }

    private void startforresult(ImageView imageView, int code) {
        if (ContextCompat.checkSelfPermission(UserInfoActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(UserInfoActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
        } else {
            if (potoHashMap.containsKey(code)) {
                Poto poto = potoHashMap.get(code);
                DetailsImageViewerPopup detailsImageViewerPopup = new DetailsImageViewerPopup(this);
                detailsImageViewerPopup.setSingleSrcView(imageView, url + poto.getIcon());
                detailsImageViewerPopup.setXPopupImageLoader(new SmartGlideImageLoader());
                detailsImageViewerPopup.isShowSaveButton(false);
                if (poto.isFirst() == 1) {
                    detailsImageViewerPopup.setTvReplaceCoverVisibility(View.GONE);
                } else {
                    detailsImageViewerPopup.setTvReplaceCoverVisibility(View.VISIBLE);
                }
                detailsImageViewerPopup.setOnReplaceClickListener(() -> {
                    InputPicture(code);
                    return null;
                });
                detailsImageViewerPopup.setOnReplaceCoverClickListener(() -> {
                    if (potoHashMap.containsKey(1)) {
                        Poto poto1 = potoHashMap.get(1);
                        poto1.setFirst(code);
                        poto.setFirst(1);
                        potoHashMap.put(1, poto);
                        potoHashMap.put(code, poto1);
                    }
                    fillPhotosUI(null);
                    return null;
                });
                new XPopup.Builder(this)
                        .asCustom(detailsImageViewerPopup)
                        .show();
                return;
            }
            InputPicture(code);
        }
    }


    private void InputPicture(int flag) {
        PictureSelector.create(this)
                .openGallery(SelectMimeType.ofImage())
                .setImageEngine(GlideEngine.createGlideEngine())
                .setSelectionMode(SelectModeConfig.SINGLE)
                .setCropEngine((fragment, srcUri, destinationUri, dataSource, requestCode) -> {
                    // 注意* 如果你实现自己的裁剪库，需要在Activity的.setResult();
                    // Intent中需要给MediaStore.EXTRA_OUTPUT，塞入裁剪后的路径；如果有额外数据也可以通过CustomIntentKey.EXTRA_CUSTOM_EXTRA_DATA字段存入；
                    UCrop uCrop = UCrop.of(srcUri, destinationUri, dataSource);
                    uCrop.setImageEngine(new UCropImageEngine() {
                        @Override
                        public void loadImage(Context context, String url, ImageView imageView) {
                            Glide.with(context).load(url)
                                    .transform(new CenterCrop())
                                    .into(imageView);
                        }

                        @Override
                        public void loadImage(Context context, Uri url, int maxWidth, int maxHeight, OnCallbackListener<Bitmap> call) {
                            Glide.with(context).asBitmap()
                                    .override(maxWidth, maxHeight)
                                    .load(url)
                                    .transform(new CenterCrop())
                                    .into(new CustomTarget<Bitmap>() {
                                        @Override
                                        public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                                            if (call != null) {
                                                call.onCall(resource);
                                            }
                                        }

                                        @Override
                                        public void onLoadFailed(@Nullable Drawable errorDrawable) {
                                            if (call != null) {
                                                call.onCall(null);
                                            }
                                        }

                                        @Override
                                        public void onLoadCleared(@Nullable Drawable placeholder) {
                                        }
                                    });
                        }
                    });
                    uCrop.withAspectRatio(1, 1);
                    uCrop.start(fragment.requireActivity(), fragment, requestCode);
                })
                .forResult(new OnResultCallbackListener<LocalMedia>() {
                    @Override
                    public void onResult(ArrayList<LocalMedia> result) {
                        if (result.isEmpty()) {
                            return;
                        }
                        if (result.get(0).getCutPath() != null) {
                            String getkey = getkey(result.get(0).getCutPath());
                            pathsfirst = getkey;
                            getTokenbyfirst(result.get(0).getCutPath(), pathsfirst);
                            potoHashMap.put(flag, new Poto(pathsfirst, flag));
                            ImageView imageView;
                            Button imageViewClose = null;
                            switch (flag) {
                                case 1:
                                    imageView = im_icon;
                                    break;
                                case 2:
                                    imageView = im1_info;
                                    imageViewClose = icon_clear2;
                                    break;
                                case 3:
                                    imageView = im2_info;
                                    imageViewClose = icon_clear3;
                                    break;
                                case 4:
                                    imageView = im3_info;
                                    imageViewClose = icon_clear4;
                                    break;
                                case 5:
                                    imageView = im4_info;
                                    imageViewClose = icon_clear5;
                                    break;
                                case 6:
                                    imageView = im5_info;
                                    imageViewClose = icon_clear6;
                                    break;
                                default:
                                    return;
                            }
                            if (imageViewClose != null) {
                                imageViewClose.setVisibility(View.VISIBLE);
                            }
                            Glide.with(MyAppliaction.getContext())
                                    .load(result.get(0).getCutPath())
                                    .transform(new CenterCrop(), new RoundedCorners(30))
                                    .into(imageView);
                        }
                    }

                    @Override
                    public void onCancel() {

                    }
                });
    }

    /**
     * 获取认证信息
     */
    private void getAuditInfo(String extra, String token) {
        NetUtils.getInstance().getApiService().getAuditInfo(extra, token)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<NumberBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(NumberBean numberBean) {
                        clearLoading();
                        String data = numberBean.getData();
                        String decryptStr;
                        try {
                            decryptStr = AESUtil.aesDecryptString(data, KEY);
                            LogUtils.i("decryptStrAditinfo", decryptStr);
                            Gson gson = new Gson();
                            AuditinfoBean auditinfoBean = gson.fromJson(decryptStr, AuditinfoBean.class);
                            if (auditinfoBean.getData().getAuditInfo().getPotos().size() > 0) {
                                Gson gson1 = new Gson();
                                userbeginlist = gson1.toJson(auditinfoBean.getData().getAuditInfo().getPotos());
                                List<Poto> photos = new Gson().fromJson(userbeginlist, new TypeToken<List<Poto>>() {
                                }.getType());
                                fillPhotosUI(photos);
                                LogUtils.i("WECHAT", auditinfoBean.getData().getAuditInfo().getWxNo());
                                if (auditinfoBean.getData().getAuditInfo().getWxNo() != null){
                                    if (!auditinfoBean.getData().getAuditInfo().getWxNo().isEmpty()) {
                                        textHaveTo.setVisibility(View.GONE);
                                        editWeChat.setText(auditinfoBean.getData().getAuditInfo().getWxNo());
                                    }
                                }
                                if (!auditinfoBean.getData().getAuditInfo().getPersionVideo().isEmpty()) {
                                    Glide.with(MyAppliaction.getContext())
                                            .load(url + auditinfoBean.getData().getAuditInfo().getPersionVideo())
                                            .transform(new CenterCrop(), new RoundedCorners(30))
                                            .into(vedio_info1);
                                    if (auditinfoBean.getData().getAuditInfo().getPersionVideo() != null) {
                                        icon_clear7.setVisibility(View.VISIBLE);
                                    } else {
                                        icon_clear7.setVisibility(View.GONE);
                                    }
                                    vedio_info.setVisibility(View.GONE);
                                    vedio_info1.setVisibility(View.VISIBLE);
                                    vedio_info1.setOnClickListener(new CustomClickListener() {
                                        @Override
                                        protected void onSingleClick() {
                                            Intent intent = new Intent(UserInfoActivity.this, SeevideoActivity.class);
                                            intent.putExtra("pathvideo", url + auditinfoBean.getData().getAuditInfo().getPersionVideo());
                                            startActivity(intent);
                                        }

                                        @Override
                                        protected void onFastClick() {

                                        }
                                    });
                                }
                                icon_shiping.setVisibility(View.VISIBLE);
                            }
                            if (auditinfoBean != null) {
                                if (auditinfoBean.getData() != null) {
                                    if (auditinfoBean.getData().getAuditInfo() != null) {
                                        if (auditinfoBean.getData().getAuditInfo().getCity() != null) {
                                            if (auditinfoBean.getData().getAuditInfo().getCity().getAdCode() != -1) {
                                                adCode = auditinfoBean.getData().getAuditInfo().getCity().getAdCode();
                                            }
                                        }
                                        if (auditinfoBean.getData().getAuditInfo().getEm() != null) {
                                            if (auditinfoBean.getData().getAuditInfo().getEm().getId() != -1) {
                                                emId = auditinfoBean.getData().getAuditInfo().getEm().getId();
                                            }
                                        }
                                        if (auditinfoBean.getData().getAuditInfo().getPro() != null) {
                                            if (auditinfoBean.getData().getAuditInfo().getPro().getId() != -1) {
                                                proid = auditinfoBean.getData().getAuditInfo().getPro().getId();
                                            }
                                        }
                                        if (auditinfoBean.getData().getAuditInfo().getUss() != null) {
                                            if (auditinfoBean.getData().getAuditInfo().getUss().getId() != -1) {
                                                ussid = auditinfoBean.getData().getAuditInfo().getUss().getId();
                                            }
                                        }
                                    }
                                }
                            }

                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }

                    @Override
                    public void onError(Throwable e) {
                        clearLoading();
                    }

                    @Override
                    public void onComplete() {
                        clearLoading();
                    }
                });
    }

    private void fillPhotosUI(List<Poto> photos) {
        if (photos != null && !photos.isEmpty()) {
            potoHashMap.clear();
            for (Poto photo : photos) {
                potoHashMap.put(photo.isFirst(), photo);
            }
        }
        for (Map.Entry<Integer, Poto> integerPotoEntry : potoHashMap.entrySet()) {
            ImageView imageView;
            Button imageViewClose = null;
            switch (integerPotoEntry.getKey()) {
                case 1:
                    imageView = im_icon;
                    break;
                case 2:
                    imageView = im1_info;
                    imageViewClose = icon_clear2;
                    break;
                case 3:
                    imageView = im2_info;
                    imageViewClose = icon_clear3;
                    break;
                case 4:
                    imageView = im3_info;
                    imageViewClose = icon_clear4;
                    break;
                case 5:
                    imageView = im4_info;
                    imageViewClose = icon_clear5;
                    break;
                case 6:
                    imageView = im5_info;
                    imageViewClose = icon_clear6;
                    break;
                default:
                    return;
            }
            if (imageViewClose != null) {
                imageViewClose.setVisibility(View.VISIBLE);
            }
            Glide.with(MyAppliaction.getContext())
                    .load(url + integerPotoEntry.getValue().getIcon())
                    .transform(new CenterCrop(), new RoundedCorners(30))
                    .into(imageView);
        }
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.im_icon:
                startforresult((ImageView) view, 1);
                break;

            case R.id.im1_info:
                startforresult((ImageView) view, 2);
                break;

            case R.id.im2_info:
                startforresult((ImageView) view, 3);
                break;

            case R.id.im3_info:
                startforresult((ImageView) view, 4);
                break;

            case R.id.im4_info:
                startforresult((ImageView) view, 5);
                break;

            case R.id.im5_info:
                startforresult((ImageView) view, 6);
                break;
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        String edRename = MmkvUtil.INSTANCE.decodeString("ed_rename");
        if (edRename != null && !edRename.isEmpty()) {
            if (tx_name != null) {
                tx_name.setText(edRename);
            }
        }
    }
}
